Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

187
Views
Trying to use "Socket.io-client" module in React throws error: Cannot assign to read only property 'exports' of object '#<Object>'

I'm using socket.io-client in my React js web app. It compiles without error, but when I try to open the development server (localhost:3000) I get the following error:

Error Screenshot

In this project where the error is being thrown, here is a list of the relevant packages and their versions:

  • @testing-library/jest-dom@5.14.1
  • @testing-library/react@11.2.7
  • @testing-library/user-event@12.8.3
  • react-dom@17.0.2
  • react-scripts@4.0.3
  • react@17.0.2
  • socket.io-client@4.3.1

Webpack Version: 4.44.2


Threads like this one suggest that this is some sort of issue with mixing import and module.exports in ES6, but I definitely don't want to modify the socket.io-client module.

In a previous React project, where the module works, here is a list of the relevant packages and their versions:

  • @testing-library/jest-dom@4.2.4
  • @testing-library/react@9.5.0
  • @testing-library/user-event@7.2.1
  • react-scripts@3.4.4
  • react@16.14.0
  • socket.io-client@4.1.2

Webpack Version: 4.42.0

I've played around a little bit with different versions of socket.io-client and react to try to get it working, but to no avail...

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

Webpack uses ES syntax, so commonJS syntax will not work.

export default lookup
about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!